
package br.com.view;

import br.com.dao.ConectaBanco;
import java.sql.Date;
import java.sql.SQLException;
import java.sql.Time;
import java.text.SimpleDateFormat;
import javax.swing.JOptionPane;

/**
 *
 * @author Cícero
 */
public class Frm_EntregaEpi extends javax.swing.JFrame {

    ConectaBanco conexao = new ConectaBanco();
    Frm_Acesso frmAcesso = new Frm_Acesso();
    
    public Frm_EntregaEpi() {
        initComponents();
        
    }
    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblIdEntrega = new javax.swing.JLabel();
        lblData = new javax.swing.JLabel();
        lblHora = new javax.swing.JLabel();
        lblEntregaEpi = new javax.swing.JLabel();
        textIdEntrega = new javax.swing.JTextField();
        lblObservacoes = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        textObservacoes = new javax.swing.JTextPane();
        btnNovaEntrega = new javax.swing.JButton();
        btnFinalizarEntrega = new javax.swing.JButton();
        btnPMatricula = new javax.swing.JButton();
        textPesquisaMatricula = new javax.swing.JTextField();
        ftextData = new javax.swing.JFormattedTextField();
        ftextHora = new javax.swing.JFormattedTextField();
        lblPesquisaMatricula = new javax.swing.JLabel();
        textPesquisaEpi = new javax.swing.JTextField();
        btnPEPI = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        lblQuantidade = new javax.swing.JLabel();
        textQuantidade = new javax.swing.JTextField();
        jScrollPane2 = new javax.swing.JScrollPane();
        tableItens = new javax.swing.JTable();
        jLabel2 = new javax.swing.JLabel();
        lblNomeMatricula = new javax.swing.JLabel();
        lblNomeFuncao = new javax.swing.JLabel();
        lblResponsavel = new javax.swing.JLabel();
        textResponsavel = new javax.swing.JTextField();
        lblNomeSetor2 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosed(java.awt.event.WindowEvent evt) {
                formWindowClosed(evt);
            }
        });
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        lblIdEntrega.setFont(new java.awt.Font("Tahoma", 3, 11)); // NOI18N
        lblIdEntrega.setText("Nº da Entrega:");
        getContentPane().add(lblIdEntrega, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 80, 90, -1));

        lblData.setFont(new java.awt.Font("Tahoma", 3, 11)); // NOI18N
        lblData.setText("Data:");
        getContentPane().add(lblData, new org.netbeans.lib.awtextra.AbsoluteConstraints(290, 80, 40, -1));

        lblHora.setFont(new java.awt.Font("Tahoma", 3, 11)); // NOI18N
        lblHora.setText("Hora:");
        getContentPane().add(lblHora, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 80, 40, -1));

        lblEntregaEpi.setFont(new java.awt.Font("Tahoma", 3, 18)); // NOI18N
        lblEntregaEpi.setText("Entrega EPI");
        getContentPane().add(lblEntregaEpi, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 20, 150, -1));

        textIdEntrega.setEnabled(false);
        getContentPane().add(textIdEntrega, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 80, 100, -1));

        lblObservacoes.setFont(new java.awt.Font("Tahoma", 3, 11)); // NOI18N
        lblObservacoes.setText("Observações:");
        getContentPane().add(lblObservacoes, new org.netbeans.lib.awtextra.AbsoluteConstraints(510, 270, 80, 20));

        textObservacoes.setEnabled(false);
        jScrollPane1.setViewportView(textObservacoes);

        getContentPane().add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(510, 290, 210, 140));

        btnNovaEntrega.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icones sysepi/favicon(42).png"))); // NOI18N
        btnNovaEntrega.setText("Nova Entrega");
        btnNovaEntrega.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNovaEntregaActionPerformed(evt);
            }
        });
        getContentPane().add(btnNovaEntrega, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 450, -1, -1));

        btnFinalizarEntrega.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icones sysepi/favicon (20).png"))); // NOI18N
        btnFinalizarEntrega.setText("Finalizar Entrega");
        getContentPane().add(btnFinalizarEntrega, new org.netbeans.lib.awtextra.AbsoluteConstraints(520, 450, -1, -1));

        btnPMatricula.setText("Pesquisa");
        btnPMatricula.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPMatriculaActionPerformed(evt);
            }
        });
        getContentPane().add(btnPMatricula, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 140, -1, -1));

        textPesquisaMatricula.setEnabled(false);
        getContentPane().add(textPesquisaMatricula, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 140, 110, -1));

        try {
            ftextData.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        ftextData.setEnabled(false);
        getContentPane().add(ftextData, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 80, 100, -1));

        try {
            ftextHora.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##:##")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        ftextHora.setEnabled(false);
        getContentPane().add(ftextHora, new org.netbeans.lib.awtextra.AbsoluteConstraints(480, 80, 70, -1));

        lblPesquisaMatricula.setFont(new java.awt.Font("Tahoma", 3, 11)); // NOI18N
        lblPesquisaMatricula.setText("Pesquise a Matricula");
        getContentPane().add(lblPesquisaMatricula, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 120, 120, -1));

        textPesquisaEpi.setEnabled(false);
        getContentPane().add(textPesquisaEpi, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 200, 190, -1));

        btnPEPI.setText("Pesquisa");
        getContentPane().add(btnPEPI, new org.netbeans.lib.awtextra.AbsoluteConstraints(370, 200, -1, -1));

        jLabel1.setFont(new java.awt.Font("Tahoma", 3, 11)); // NOI18N
        jLabel1.setText("Pesquise o  EPI");
        getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 180, 90, -1));

        lblQuantidade.setFont(new java.awt.Font("Tahoma", 3, 11)); // NOI18N
        lblQuantidade.setText("Quantidade");
        getContentPane().add(lblQuantidade, new org.netbeans.lib.awtextra.AbsoluteConstraints(460, 180, 80, -1));

        textQuantidade.setEnabled(false);
        getContentPane().add(textQuantidade, new org.netbeans.lib.awtextra.AbsoluteConstraints(460, 200, 80, -1));

        jScrollPane2.setViewportView(tableItens);

        getContentPane().add(jScrollPane2, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 290, 440, 140));

        jLabel2.setFont(new java.awt.Font("Tahoma", 3, 14)); // NOI18N
        jLabel2.setText("Itens Para Entrega");
        getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 270, 140, -1));

        lblNomeMatricula.setBackground(new java.awt.Color(255, 255, 255));
        lblNomeMatricula.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        getContentPane().add(lblNomeMatricula, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 230, 220, 20));

        lblNomeFuncao.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        getContentPane().add(lblNomeFuncao, new org.netbeans.lib.awtextra.AbsoluteConstraints(510, 230, 210, 20));

        lblResponsavel.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lblResponsavel.setText("Responsável:");
        getContentPane().add(lblResponsavel, new org.netbeans.lib.awtextra.AbsoluteConstraints(570, 80, -1, -1));

        textResponsavel.setEnabled(false);
        getContentPane().add(textResponsavel, new org.netbeans.lib.awtextra.AbsoluteConstraints(660, 80, 110, -1));

        lblNomeSetor2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        getContentPane().add(lblNomeSetor2, new org.netbeans.lib.awtextra.AbsoluteConstraints(290, 230, 210, 20));

        setSize(new java.awt.Dimension(924, 554));
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void btnNovaEntregaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNovaEntregaActionPerformed
       ftextData.setText(new SimpleDateFormat("dd/MM/yyyy").format(new Date(System.currentTimeMillis()))); 
       ftextHora.setText(new SimpleDateFormat("hh:mm:ss").format(new Time(System.currentTimeMillis())));
        NovaEntrada();
    }//GEN-LAST:event_btnNovaEntregaActionPerformed

    private void btnPMatriculaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPMatriculaActionPerformed
        
    }//GEN-LAST:event_btnPMatriculaActionPerformed

    private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
        try {
            this.conexao.con.close();
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, "Erro ao fecha o formulario"+ex);
        }
    }//GEN-LAST:event_formWindowClosed

    private void NovaEntrada() {
        
        textPesquisaEpi.setEnabled(true);
        textPesquisaMatricula.setEnabled(true);
        textObservacoes.setEnabled(true);
        textQuantidade.setEnabled(true);
        textPesquisaMatricula.requestFocus();
        textResponsavel.setText("Admin");
         
    }
    
     private Date converteData(String data) {                    
        Date d = null;     
        try {     
            data = data.substring(6) + "-" +     
                    data.substring(3, 5) + "-" +     
                    data.substring(0, 2);     
            d = Date.valueOf(data);     
        } catch (Exception ex) {     
            ex.printStackTrace();     
        }     
        return d;     
    }
    
    
    
    

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnFinalizarEntrega;
    private javax.swing.JButton btnNovaEntrega;
    private javax.swing.JButton btnPEPI;
    private javax.swing.JButton btnPMatricula;
    private javax.swing.JFormattedTextField ftextData;
    private javax.swing.JFormattedTextField ftextHora;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel lblData;
    private javax.swing.JLabel lblEntregaEpi;
    private javax.swing.JLabel lblHora;
    private javax.swing.JLabel lblIdEntrega;
    private javax.swing.JLabel lblNomeFuncao;
    private javax.swing.JLabel lblNomeMatricula;
    private javax.swing.JLabel lblNomeSetor2;
    private javax.swing.JLabel lblObservacoes;
    private javax.swing.JLabel lblPesquisaMatricula;
    private javax.swing.JLabel lblQuantidade;
    private javax.swing.JLabel lblResponsavel;
    private javax.swing.JTable tableItens;
    private javax.swing.JTextField textIdEntrega;
    private javax.swing.JTextPane textObservacoes;
    private javax.swing.JTextField textPesquisaEpi;
    private javax.swing.JTextField textPesquisaMatricula;
    private javax.swing.JTextField textQuantidade;
    private javax.swing.JTextField textResponsavel;
    // End of variables declaration//GEN-END:variables

    
}
